let arr1 = [1, 2, 3, 4, 5]
let arr2 = [2, 7, 3, 4]
// arr1.sum()返回这个对象的所有数值的和
let arr3 = new Array()
let arr4 = []

let obj1 = {}
let obj2 = new Object()
/**
 * 1.确定数组的构造函数
 * 2.给原型添加sum方法
 */

Array.prototype.sum = function () {
    let res = 0
    this.forEach(function (item) {
        res += item
    })
    return res
}

//手写一个_slice
//arr1.slice() arr1.slice(1) arr1.slice(2)
Array.prototype._slice = function (start = 0, end = this.length) {
    let res = []
    for (let i = start; i < end; i++) {
        res.push(this[i])
    }
    return res
}
Array.prototype._push = function () {
    for (let arg of arguments) {
        this[this.length] = arg
    }
    return this.length
}